# pip install selenium
# pip install webdriver-manager
# 自动更新 https://zhuanlan.zhihu.com/p/606145341
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By

# 下载好路径为： C://Users//test//.wdm//drivers//chromedriver//win64//119.0.6045.105//chromedriver-win32//chromedriver.exe
# driver = webdriver.Chrome(service=ChromeService(
#     ChromeDriverManager().install()))

# 并加载浏览器的静默模式
# option = webdriver.ChromeOptions()
# option.add_experimental_option("excludeSwitches", ['enable-automation'])
# option.add_argument("--disable-blink-features=AutomationControlled")
# option.add_argument('disable-infobars')

driver = webdriver.Chrome(service=ChromeService(
    executable_path='C://Users//test//.wdm//drivers//chromedriver//win64//119.0.6045.105//chromedriver-win32//chromedriver.exe',
    # option=option
))

driver.maximize_window()

# 打开一个网页
driver.get('https://www.baidu.com')

# 获取input输入selenium
driver.find_element(By.ID, "kw").send_keys("selenium")
# 点击跳转
driver.find_element(By.ID, "su").click()

time.sleep(2)
# 打印页面标题做校验
print(driver.title)
time.sleep(2000000)
driver.quit()
